import { getReportHistory } from '@/api/record'

export default {
  data () {
    return {
      loading: false,
      lists: [],
      pagination: {
        pageNumber: 1,
        pageSize: 5,
        total: 0,
      }
    }
  },
  computed: {
    themeColor () {
      return this.$store.state.user.theme
    },
    userInfo () {
      return this.$store.state.user.userInfo || {}
    },
    enterpriseId () {
      const { tenantId } = this.userInfo
      return tenantId ? String(tenantId) : null
    },
  },
  methods: {
    async getLists (params) {
      this.loading = true
      try {
        const { data = {} } = await getReportHistory(params)
        this.lists = (data.records || []).map(v => ({
          time: v.creationTime,
          type: v.eventType,
          user: v.creationName,
          remark: v.mark,
        }));
        this.pagination.total = data.total || 0;
      } finally {
        this.loading = false
      }
    },
  },
}
